<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        setTimeout(() => console.log(1), 0)  //2 abc 3 4 
        async function main() {
            console.log('2')
            await new Promise(resolve => {   //等待await后面跟的代码执行完毕，才能执行console.log('3)
                console.log('abc')
                setTimeout(resolve, 0)
            })
            console.log('3')
        }
        main()
        Promise.resolve().then(() => console.log('4'))
    </script>
</body>

</html>